﻿@model Project.Domain.Entities.Match
@{
    ViewBag.Title = "listmatches";
}
<h2>listmatches</h2>
<label>Chọn giải đấu</label>
<br />
@Html.DropDownList("LeagueID")
<div id="listmatchable">

</div>

<a href="#" id="insertmatch">Insert Match</a>

<div id="insertmatchform" style=" display:none; ">
@Html.ValidationSummary()
@{Html.EnableClientValidation();}
    @using (Html.BeginForm("InsertMatch", "Managebets",FormMethod.Post))
    {
        <label>Chọn giải đấu</label>
        <br />
        @Html.DropDownList("LeagueID")
        @Html.ValidationMessageFor(m => m.LeagueId)
        <br />
        <label>Chọn chủ nhà</label>
        <br />
        @Html.DropDownList("HomeTeamID")
        @Html.ValidationMessageFor(m => m.HomeTeam)
        <br />
        <label>đội khách</label>
        <br />
        @Html.DropDownList("AwayTeamID")
         @Html.ValidationMessageFor(m => m.AwayTeam)
        <br />
        <label>thời gian bắt đầu</label>
        <br />        
        <input type="submit" name="name" value="save" />
    }

</div>
<script type="text/javascript">
    $(document).ready(function () {
        $.post('@Url.Action("ListAllMatches", "managebets")', function (data) {
            $("#listmatchable").html(data);
            return false;
        });        

        $("#insertmatch").click(function () {            
                $("#insertmatchform").show();
                return false;
            });

        $("#LeagueID").change(function () {
            var id = $(this).attr('value');
            $.post('@Url.Action("GetAllMatchesByLeagueId","managebets")', { leagueid: id }, function (data) {
                $("#listmatchable").html(data);
                return false;
            });
        });
    });

</script>